﻿using BO;
using BO.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Dynamic;
using WebUI;
using System.Web.Script.Serialization;
namespace WebUI.Controllers
{
    public class CompanyController : BaseController
    {
        public ViewResult Index()
        {
            return View();
        }
        public JsonResult GetList()
        {
            var list = ListFactory<CompanyList>.GetList("");
            return Json(list.ToModel());
        }
        public JsonResult SaveList()
        {
            string deleted = Request.Form["deleted"];
            string inserted = Request.Form["inserted"];
            string updated = Request.Form["updated"];
            var jsObj = new JavaScriptSerializer();

            if (deleted != null)
            {
                //把json字符串转换成对象
                List<Company> listDeleted = jsObj.Deserialize<List<Company>>(deleted);
                //TODO 下面就可以根据转换后的对象进行相应的操作了
            }

            if (inserted != null)
            {
                //把json字符串转换成对象
                List<Company> listInserted = jsObj.Deserialize<List<Company>>(inserted);
            }

            if (updated != null)
            {
                //把json字符串转换成对象
                List<Company> listUpdated = jsObj.Deserialize<List<Company>>(updated);
            }

            return Json("Success");
        }
     
    }
}
